import os
# 路径生成文件
print("---------------------------------------------------------------")

path = "D:/deeplearning/EGNet/data/images"

desktop_path = "D:/deeplearning/EGNet/data"

file_name = 'test.lst'

full_path = desktop_path + '/' + file_name # 文件地址和文件名

if not os.access(full_path, os.F_OK):   # 判断文件是否存在
    file = open(full_path, 'w')

    # 获取指定目录下文件的文件名，加上绝对路径，一行一行写入指定文件中
    for root, dirs, PicNameList in os.walk(path):
        #print(PicNameList)
        for picname in PicNameList:
            full_picpath = root + '/' + picname + '\n'
            #print(full_picpath)
            file.write(full_picpath)

        file.close()
        print("成功！")
else:
    print("您输入的文件已经存在，请重新输入")
